package handler

import (
	"car-trade-sys/model"
	"github.com/gin-gonic/gin"
)

func Car(c *gin.Context) {
	name := c.PostForm("name")
	price := c.PostForm("price")
	data := model.Car{
		Name:  name,
		Price: price,
	}
	err := model.DB.Create(&data).Debug().Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 500,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
	return
}
